// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.nnee.p_pr.p_activity.p_view;

import android.content.Context;
import android.graphics.*;
import android.os.Handler;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.*;
import android.widget.FrameLayout;
import com.nnee.p_img.cls_d;
import com.nnee.p_pr.p_activity.cr;
import com.nnee.p_pr.p_atom.cls_u;
import java.util.*;

// Referenced classes of package com.nnee.p_pr.p_activity.view:
//            bp, am, ak, aj, 
//            cb, at, RelativeLayoutEx, cc, 
//            d

public class cls_PRISGridView extends ViewGroup
    implements cls_bp
{

    public cls_PRISGridView(Context context)
    {
        this(context, null);
    }

    public cls_PRISGridView(Context context, AttributeSet attributeset)
    {
        this(context, attributeset, 0);
    }

    public cls_PRISGridView(Context context, AttributeSet attributeset, int i1)
    {
        super(context, attributeset, i1);
        i = -1;
        j = -1;
        k = 0;
        l = 0;
        m = 0;
        q = new cls_am(this);
        r = new cls_ak(this);
        s = false;
        u = new LinkedList();
        w = new Rect();
        x = null;
        y = -1;
        z = -1;
        C = new cls_aj(this);
        b();
    }

    private int a(String s1, int i1, int j1)
    {
        if(!TextUtils.isEmpty(s1) && i1 >= 0 && j1 >= 0) goto _L2; else goto _L1
_L1:
        int k1 = -1;
_L4:
        return k1;
_L2:
        int l1 = i1;
        do
        {
            if(l1 > j1)
                break;
            if(((u)f.getItem(l1)).V().equals(s1))
            {
                k1 = l1;
                continue; /* Loop/switch isn't completed */
            }
            l1++;
        } while(true);
        k1 = -1;
        if(true) goto _L4; else goto _L3
_L3:
    }

    private View a(int i1, int j1, boolean flag)
    {
        Rect rect;
        int k1;
        int l1;
        int i2;
        rect = w;
        k1 = i1 + getScrollX();
        l1 = j1 + getScrollY();
        i2 = getChildCount();
_L5:
        if(i2 < 0) goto _L2; else goto _L1
_L1:
        View view = getChildAt(i2);
        if(view != null && view.getVisibility() == 0 && (view != t || flag)) goto _L4; else goto _L3
_L3:
        i2--;
          goto _L5
_L4:
        view.getHitRect(rect);
        if(!rect.contains(k1, l1)) goto _L3; else goto _L6
_L6:
        return view;
_L2:
        view = null;
        if(true) goto _L6; else goto _L7
_L7:
    }

    static com.nnee.p_pr.p_activity.p_view.cls_d a(cls_PRISGridView prisgridview)
    {
        return prisgridview.n;
    }

    private void a(MotionEvent motionevent)
    {
        int i1;
        int j1;
        i1 = (int)motionevent.getX();
        j1 = (int)motionevent.getY();
        motionevent.getAction();
        JVM INSTR tableswitch 0 2: default 44
    //                   0 45
    //                   1 224
    //                   2 194;
           goto _L1 _L2 _L3 _L4
_L1:
        return;
_L2:
        if(t == null && u.isEmpty() && !C.hasMessages(-1))
        {
            t = a(i1, j1, true);
            if(t != null)
            {
                y = i1 - t.getLeft();
                z = j1 - t.getTop();
                x = new Rect(t.getLeft(), t.getTop(), t.getLeft() + t.getWidth(), t.getTop() + t.getHeight());
                a(t, (int)motionevent.getRawX(), (int)motionevent.getRawY());
            }
        }
        continue; /* Loop/switch isn't completed */
_L4:
        if(t != null)
        {
            b((int)motionevent.getRawX(), (int)motionevent.getRawY());
            c(i1, j1);
        }
        continue; /* Loop/switch isn't completed */
_L3:
        if(t != null)
        {
            t.layout(x.left, x.top, x.right, x.bottom);
            d();
            x = null;
            t = null;
        }
        if(true) goto _L1; else goto _L5
_L5:
    }

    private void a(View view, int i1, int j1)
    {
        if(view != null && p != null)
        {
            view.setDrawingCacheEnabled(true);
            Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache());
            A = bitmap;
            p.a(i1 - y, j1 - z, bitmap);
        }
        view.setVisibility(4);
    }

    private void a(View view, View view1)
    {
        if(view != null && view1 != null && view != view1)
        {
            int i1 = ((Integer)view.getTag()).intValue();
            int j1 = ((Integer)view1.getTag()).intValue();
            ArrayList arraylist = new ArrayList();
            ArrayList arraylist1 = new ArrayList();
            Rect rect = new Rect(x);
            if(i1 < j1)
            {
                for(int l1 = i1 + 1; l1 <= j1; l1++)
                {
                    Rect rect2 = new Rect();
                    View view3 = m(l1);
                    rect2.set(view3.getLeft(), view3.getTop(), view3.getRight(), view3.getBottom());
                    arraylist1.add(new cls_at(this, view3, rect2, rect));
                    arraylist.add(view3);
                    rect = new Rect(rect2);
                }

            } else
            {
                for(int k1 = i1 + -1; k1 >= j1; k1--)
                {
                    Rect rect1 = new Rect();
                    View view2 = m(k1);
                    rect1.set(view2.getLeft(), view2.getTop(), view2.getRight(), view2.getBottom());
                    arraylist1.add(new cls_at(this, view2, rect1, rect));
                    arraylist.add(view2);
                    rect = new Rect(rect1);
                }

            }
            arraylist.add(view);
            boolean flag;
            if(i1 < j1)
                flag = true;
            else
                flag = false;
            a(arraylist, i1, 1, flag);
            a(arraylist1);
        }
    }

    private void a(ViewGroup viewgroup, View view)
    {
        if(viewgroup != null && view != null && view.getParent() == null)
        {
            viewgroup.addView(view, new android.view.ViewGroup.LayoutParams(-1, -1));
            view.setOnClickListener(q);
            view.setOnCreateContextMenuListener(r);
            view.setFocusable(true);
            ((cls_RelativeLayoutEx)view).a(0x7f0200ee);
        }
    }

    private void a(ArrayList arraylist)
    {
        if(arraylist == null)
            break MISSING_BLOCK_LABEL_92;
        LinkedList linkedlist = u;
        linkedlist;
        JVM INSTR monitorenter ;
        at at1;
        for(Iterator iterator = arraylist.iterator(); iterator.hasNext(); u.addLast(at1))
            at1 = (at)iterator.next();

        break MISSING_BLOCK_LABEL_56;
        Exception exception;
        exception;
        throw exception;
        u.notify();
        linkedlist;
        JVM INSTR monitorexit ;
        if(v == null)
        {
            v = new cc(this, null);
            v.start();
        }
    }

    private void a(ArrayList arraylist, int i1, int j1, boolean flag)
    {
        if(arraylist != null && arraylist.size() != 0) goto _L2; else goto _L1
_L1:
        return;
_L2:
        if(!flag)
            break; /* Loop/switch isn't completed */
        int l1 = 0;
        while(l1 < arraylist.size()) 
        {
            ((View)arraylist.get(l1)).setTag(Integer.valueOf(i1 + l1 * j1));
            l1++;
        }
        if(true) goto _L1; else goto _L3
_L3:
        int k1 = 0;
        while(k1 < arraylist.size()) 
        {
            ((View)arraylist.get(k1)).setTag(Integer.valueOf(i1 - k1 * j1));
            k1++;
        }
        if(true) goto _L1; else goto _L4
_L4:
    }

    static android.view.View.OnCreateContextMenuListener b(cls_PRISGridView prisgridview)
    {
        return prisgridview.o;
    }

    private void b()
    {
        Context context = getContext();
        FrameLayout framelayout = new FrameLayout(context);
        FrameLayout framelayout1 = new FrameLayout(context);
        FrameLayout framelayout2 = new FrameLayout(context);
        FrameLayout framelayout3 = new FrameLayout(context);
        FrameLayout framelayout4 = new FrameLayout(context);
        FrameLayout framelayout5 = new FrameLayout(context);
        addView(framelayout, 0);
        addView(framelayout1, 1);
        addView(framelayout2, 2);
        addView(framelayout3, 3);
        addView(framelayout4, 4);
        addView(framelayout5, 5);
    }

    private void b(int i1, int j1)
    {
        if(p != null)
            p.a(i1 - y, j1 - z);
    }

    static Handler c(cls_PRISGridView prisgridview)
    {
        return prisgridview.C;
    }

    private void c()
    {
        if(j >= 0)
            com.nnee.p_img.cls_d.a().a(j, 256);
    }

    private void c(int i1, int j1)
    {
        if(u.isEmpty() && !C.hasMessages(-1)) goto _L2; else goto _L1
_L1:
        return;
_L2:
        View view = a(i1, j1, false);
        if(view != null)
        {
            int k1 = view.getLeft();
            int l1 = view.getTop();
            int i2 = view.getRight();
            int j2 = view.getBottom();
            a(t, view);
            x.set(k1, l1, i2, j2);
        }
        if(true) goto _L1; else goto _L3
_L3:
    }

    static LinkedList d(cls_PRISGridView prisgridview)
    {
        return prisgridview.u;
    }

    private void d()
    {
        t.setVisibility(0);
        if(A != null)
        {
            A.recycle();
            A = null;
        }
        if(p != null)
            p.a();
    }

    private int k(int i1)
    {
        return (android.view.View.MeasureSpec.getSize(i1) - 1 * k) / 2;
    }

    private int l(int i1)
    {
        return (android.view.View.MeasureSpec.getSize(i1) - 2 * l) / 3;
    }

    private View m(int i1)
    {
        int j1 = getChildCount();
_L3:
        View view1;
        if(j1 < 0)
            break; /* Loop/switch isn't completed */
        view1 = getChildAt(j1);
          goto _L1
_L5:
        j1--;
        if(true) goto _L3; else goto _L2
_L1:
        if(view1 == null || ((Integer)view1.getTag()).intValue() != i1) goto _L5; else goto _L4
_L4:
        View view = view1;
_L7:
        return view;
_L2:
        view = null;
        if(true) goto _L7; else goto _L6
_L6:
    }

    public int a()
    {
        return i;
    }

    protected int a(ViewParent viewparent)
    {
        int i1 = 0;
_L3:
        if(i1 >= getChildCount())
            break MISSING_BLOCK_LABEL_37;
        if(getChildAt(i1) != viewparent) goto _L2; else goto _L1
_L1:
        int j1 = i1 + 6 * i;
_L4:
        return j1;
_L2:
        i1++;
          goto _L3
        j1 = -1;
          goto _L4
    }

    public Object a(int i1, int j1, Object obj)
    {
        return null;
    }

    public void a(int i1)
    {
        k = i1;
    }

    public void a(int i1, int j1)
    {
        h = i1;
        g = j1;
    }

    public void a(int i1, boolean flag)
    {
    }

    public void a(android.view.View.OnCreateContextMenuListener oncreatecontextmenulistener)
    {
        o = oncreatecontextmenulistener;
    }

    public void a(cr cr1)
    {
        f = cr1;
    }

    public void a(cb cb1)
    {
        p = cb1;
    }

    public void a(com.nnee.p_pr.p_activity.p_view.cls_d d1)
    {
        n = d1;
    }

    public boolean a(String s1)
    {
        boolean flag;
        if(f == null)
        {
            flag = false;
        } else
        {
            int i1 = 6 * i;
            int j1 = a(s1, i1, Math.min(-1 + (i1 + 6), -1 + f.a()));
            if(j1 < 0)
            {
                flag = false;
            } else
            {
                FrameLayout framelayout = (FrameLayout)c(j1 - i1);
                byte byte0;
                if(h == g)
                    byte0 = 3;
                else
                    byte0 = 2;
                a(((ViewGroup) (framelayout)), f.a(j1, framelayout, framelayout.getChildAt(0), j, byte0));
                flag = true;
            }
        }
        return flag;
    }

    public void b(int i1)
    {
        l = i1;
    }

    public boolean b(int i1, int j1, Object obj)
    {
        return false;
    }

    public boolean b(String s1)
    {
        boolean flag;
        if(f == null)
        {
            flag = false;
        } else
        {
            int i1 = 6 * i;
            int j1 = a(s1, i1, Math.min(-1 + (i1 + 6), -1 + f.a()));
            if(j1 < 0)
            {
                flag = false;
            } else
            {
                FrameLayout framelayout = (FrameLayout)c(j1 - i1);
                f.a(j1, s1, framelayout.getChildAt(0));
                flag = true;
            }
        }
        return flag;
    }

    public View c(int i1)
    {
        View view;
        if(i1 < 0 || i1 >= 6)
            view = null;
        else
            view = getChildAt(i1);
        return view;
    }

    public void d(int i1)
    {
        i = i1;
    }

    public boolean dispatchTouchEvent(MotionEvent motionevent)
    {
        boolean flag;
        if(!s)
        {
            flag = super.dispatchTouchEvent(motionevent);
        } else
        {
            a(motionevent);
            flag = true;
        }
        return flag;
    }

    public void e(int i1)
    {
        h = i1;
    }

    public void f(int i1)
    {
        B = i1;
    }

    public void g(int i1)
    {
        if(f != null)
        {
            c();
            j = f.a(i);
            byte byte0;
            int j1;
            int k1;
            if(h == g)
                byte0 = 3;
            else
                byte0 = 2;
            j1 = 6 * i;
            int l1;
            for(k1 = 0; j1 <= -1 + f.a() && k1 < 6; k1 = l1)
            {
                FrameLayout framelayout = (FrameLayout)c(k1);
                framelayout.setVisibility(0);
                a(framelayout, f.a(j1, framelayout, framelayout.getChildAt(0), j, byte0));
                l1 = k1 + 1;
                j1++;
            }

            while(k1 < 6) 
            {
                ((FrameLayout)c(k1)).setVisibility(4);
                k1++;
            }
        }
    }

    public void h(int i1)
    {
    }

    public void i(int i1)
    {
        cls_d d1 = com.nnee.p_img.cls_d.a();
        int j1 = j;
        byte byte0;
        if(i1 == g)
            byte0 = 3;
        else
            byte0 = 2;
        d1.a(j1, byte0);
    }

    public void j(int i1)
    {
        m = i1;
    }

    protected void onAttachedToWindow()
    {
        super.onAttachedToWindow();
    }

    protected void onDraw(Canvas canvas)
    {
        super.onDraw(canvas);
    }

    protected void onFinishInflate()
    {
        super.onFinishInflate();
    }

    protected void onLayout(boolean flag, int i1, int j1, int k1, int l1)
    {
        for(int i2 = 0; i2 < 3; i2++)
        {
            for(int j2 = 0; j2 < 2; j2++)
            {
                int k2 = j2 + i2 * 2;
                View view = getChildAt(k2);
                if(view != null && view.getVisibility() != 8)
                {
                    int l2 = view.getMeasuredWidth();
                    int i3 = view.getMeasuredHeight();
                    int j3 = j2 * (l2 + k);
                    int k3 = i2 * (i3 + l);
                    view.layout(j3, k3, l2 + j3, i3 + k3);
                    view.setTag(new Integer(k2));
                }
            }

        }

    }

    protected void onMeasure(int i1, int j1)
    {
        super.onMeasure(i1, j1);
        if(android.view.View.MeasureSpec.getMode(i1) != 0x40000000)
            throw new IllegalStateException("Workspace can only be used in EXACTLY mode.");
        if(android.view.View.MeasureSpec.getMode(j1) != 0x40000000)
            throw new IllegalStateException("Workspace can only be used in EXACTLY mode.");
        int k1 = k(i1);
        int l1 = l(j1);
        int i2 = android.view.View.MeasureSpec.makeMeasureSpec(k1, 0x80000000);
        int j2 = android.view.View.MeasureSpec.makeMeasureSpec(l1, 0x80000000);
        int k2 = getChildCount();
        for(int l2 = 0; l2 < k2; l2++)
            measureChild(getChildAt(l2), i2, j2);

    }

    public boolean onTouchEvent(MotionEvent motionevent)
    {
        super.onTouchEvent(motionevent);
        return true;
    }

    public static final int a = 2;
    public static final int b = 3;
    public static final int c = 6;
    private static final String d = "PRISGridView";
    private static final int e = -1;
    private Bitmap A;
    private int B;
    private Handler C;
    private cr f;
    private int g;
    private int h;
    private int i;
    private int j;
    private int k;
    private int l;
    private int m;
    private com.nnee.p_pr.p_activity.p_view.cls_d n;
    private android.view.View.OnCreateContextMenuListener o;
    private cb p;
    private android.view.View.OnClickListener q;
    private android.view.View.OnCreateContextMenuListener r;
    private boolean s;
    private View t;
    private LinkedList u;
    private cc v;
    private Rect w;
    private Rect x;
    private int y;
    private int z;
}
